import { useCallback } from 'react';
import ChartsItem from '../../../components/chartsItem';
import { getKData } from '../../../api/data';

const DataCabinet = () => {
  const createKDataOption = useCallback((data) => {
    const types = ['1号柜', '2号柜', '3号柜', '4号柜']
    return {
      tooltip: {
        trigger: 'axis',
      },
      legend: {
        data: types,
      },
      grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true,
      },
      toolbox: {
        feature: {
          saveAsImage: {},
        },
      },
      xAxis: {
        type: 'category',
        boundaryGap: false,
        data: data?.x,
      },
      yAxis: {
        type: 'value',
      },
      series: types.map((item, index) => ({
        name: item,
        type: 'line',
        stack: 'Total',
        data: data?.val[index],
      })),
    }
  }, [])
  return (
    <ChartsItem getData={getKData} createData={createKDataOption} />
  )
}
export default DataCabinet;
